package Test6;

public class Trapezoid extends Figure{
    private double h;
    private double upBorder;
    private double downBorder;
    private double rightBorder;
    private double leftBorder;

    public Trapezoid() {
    }
    public Trapezoid(double h, double upBorder, double downBorder, double rightBorder, double leftBorder) {
        this.h = h;
        this.upBorder = upBorder;
        this.downBorder = downBorder;
        this.rightBorder = rightBorder;
        this.leftBorder = leftBorder;
    }

    public double getH() {
        return h;
    }
    public void setH(double h) {
        this.h = h;
    }
    public double getUpBorder() {
        return upBorder;
    }
    public void setUpBorder(double upBorder) {
        this.upBorder = upBorder;
    }
    public double getDownBorder() {
        return downBorder;
    }
    public void setDownBorder(double downBorder) {
        this.downBorder = downBorder;
    }
    public double getRightBorder() {
        return rightBorder;
    }
    public void setRightBorder(double rightBorder) {
        this.rightBorder = rightBorder;
    }
    public double getLeftBorder() {
        return leftBorder;
    }
    public void setLeftBorder(double leftBorder) {
        this.leftBorder = leftBorder;
    }

    @Override
    public void perimeter() {
        System.out.println("梯形周长为:"+(this.getLeftBorder()+this.getRightBorder()+this.getUpBorder()+this.getDownBorder()));
    }

    @Override
    public void area() {
        System.out.println("梯形面积为:"+((this.getUpBorder()+this.getDownBorder())*this.getH())/2);
    }
}
